/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package persistence.dao.mysql;

import persistence.entites.POI;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;

/**
 *
 * @author Anthony
 */
public class POIDAO extends MySQLDAO<POI>{

    public POIDAO(EntityManager em, Class<?> classe) {
        super(em, classe);
    }

    public List<POI> findByName(String name) {
        String className = classe.getSimpleName();
        String textQuery = "select o from " + className + " as o where o.name = :objectname";
        Query query = em.createQuery(textQuery);
        query.setParameter("objectname", name);
        return  query.getResultList();
    }

    @Override
    public boolean delete(POI object) {
        object.getTag().setPoi(null);
        return super.delete(object);
    }
}
